package com.lsp.server.common;

/**
 * 统一返回值
 *
 * @author
 * @version 1.0
 * @date 2021/10/17 19:03:51
 */
public class Apiresponse {
    private Integer code;
    private String msg;
    private Object data;


    //成功
    public static Apiresponse success(Object data){
        Apiresponse apiresponse =new Apiresponse();
        apiresponse.setCode(200);
        apiresponse.setMsg("处理成功");
        apiresponse.setData(data);
        return apiresponse;
    }

    //失败
    public static Apiresponse Error (Integer code, String msg){
        Apiresponse apiresponse =new Apiresponse();
        apiresponse.setData(null);
        apiresponse.setMsg("处理失败:"+msg);
        apiresponse.setCode(500);
        return apiresponse;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
